﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class DataFields
    {
        public static void DataFields1(Dictionary<string, Object> data)  //单行
        {
            ///最小线宽0.35；平行线的间隙不小于较粗线宽的两倍，最小值不小于0.7；
            ///汉字高度不小于7mm，其他则是不小于5mm；汉字字距1.5mm，行距2mm，其他字符间距0.35/0.5mm，词距1.05/1.5mm，行距1mm
            ///
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //参数
            string property = Convert.ToString(data["property"]);
            string parameter = Convert.ToString(data["parameter"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            Vector2 v1 = new Vector2(-39, 0);
            Vector2 v2 = new Vector2(v1.X, 10);
            Vector2 v3 = new Vector2(0, 10);
            Vector2 v4 = new Vector2(0, 0);
            Vector2 v5 = new Vector2(39, 0);
            Vector2 v6 = new Vector2(39, 10);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.35, contour);
            Vector2[] Line2 = { v2, v6 };
            fun.drawBLine(dxf, Line2, 0.35, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.35, contour);
            Vector2[] Line4 = { v1, v5 };
            fun.drawBLine(dxf, Line4, 0.35, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.35, contour);
            //数据位置
            TextStyle style = new TextStyle("simsun.ttf");
            Dictionary<string, Vector2> positions = new Dictionary<string, Vector2>();
            fun.writetext(dxf, property, new Vector2(-19.5, 5), 3.5, 0, 0.6, "C");
            fun.writetext(dxf, parameter, new Vector2(19.5, 5), 3.5, 0, 0.6, "C");
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
